<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">    
    <title>IFE ECMAScript</title>
</head>
<body>        
    <div id="time"></div>
    
</body>
</html>
<script>
   function baozhuang({newYear,nowYue,nowRi,Hour,Minute,Second}){//组合一下
        var week = getWeek(new Date());
        document.getElementById('time').innerHTML = week +  newYear + '年' + nowYue + '月' + nowRi + '日' + Hour + ':' + Minute + ':' + Second
   }
//获取并    判断是否加零
   function getshifou(nowDate){
        var newYear = nowDate.getFullYear();
        var nowYue = nowDate.getMonth() + 1 ;
        var nowRi = nowDate.getDate();
        var Hour = nowDate.getHours();
        var Minute = nowDate.getMinutes();
        var Second = nowDate.getSeconds();
        nowYue = nowYue > 9 ? nowYue : '0' + nowYue;
        nowRi = nowRi > 9 ? nowRi : '0' + nowRi;
        Hour = Hour > 9 ? Hour : '0' + Hour;
        Minute = Minute > 9 ? Minute : '0' + Minute;
        Second = Second > 9 ? Second : '0' + Second;
        baozhuang({newYear,nowYue,nowRi,Hour,Minute,Second})
   }
   setInterval('getshifou(new Date())',1000);
  
//   获取星期
   function getWeek(nowDate){
     var day = '';
     switch (nowDate.getDay()) {
        case 0:
            day = "星期天";
            break;
        case 1:
            day = "星期一";
            break;
        case 2:
            day = "星期二";
            break;
        case 3:
            day = "星期三";
            break;
        case 4:
            day = "星期四";
            break;
        case 5:
            day = "星期五";
            break;
        case 6:
            day = "星期六";
    }
    return day;
   }
</script>